Skip to content

Conversation

@bajtos
Copy link
Contributor

@bajtos bajtos commented Jan 7, 2026

Update the demo app to show remaining egress allowances for each data set where the FilBeam service is enabled.

Screenshot showing the new version in practice:

Screenshot 2026-01-13 at 11 02 14
version 2 using FolderSync icon Screenshot 2026-01-07 at 12 24 56
version 1 using RefreshCw icon Screenshot 2026-01-07 at 12 11 31

@bajtos bajtos requested review from juliangruber and pyropy January 7, 2026 11:12
@github-project-automation github-project-automation bot moved this to 📌 Triage in FOC Jan 7, 2026
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 7, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
synapse-dev 164bc70 Commit Preview URL

Branch Preview URL
Jan 14 2026, 11:27 AM

@rjan90 rjan90 moved this from 📌 Triage to 🔎 Awaiting review in FOC Jan 7, 2026
@rjan90 rjan90 added this to the M4: Filecoin Service Liftoff milestone Jan 7, 2026
Signed-off-by: Miroslav Bajtoš <[email protected]>
@rjan90 rjan90 moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FOC Jan 7, 2026
@rvagg
Copy link
Collaborator

rvagg commented Jan 8, 2026

This seems fine to me and I appreciate the AGENTS.md edits but I'm going to leave it to @hugomrdias to review

@rvagg rvagg removed their request for review January 8, 2026 08:04
@BigLep BigLep moved this from ✔️ Approved by reviewer to 🔎 Awaiting review in FOC Jan 8, 2026
- Change format to "Egress remaining: X GiB delivery · Y GiB cache-miss"
- Remove FolderSync icon, keep Globe icon with tooltip "This data set is using CDN"
- Use binary units (KiB, MiB, GiB, TiB) instead of decimal units

Co-Authored-By: Claude Code <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
@bajtos bajtos requested review from juliangruber and pyropy January 13, 2026 10:12
@bajtos
Copy link
Contributor Author

bajtos commented Jan 13, 2026

I addressed the review comments, this PR is ready for another round of reviews. 🙏🏻

Copy link
Member

@pyropy pyropy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻

Comment on lines 45 to 55
export function formatBytes(bytes: bigint | number): string {
const num = typeof bytes === 'bigint' ? Number(bytes) : bytes
if (num === 0) return '0 B'

const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB']
const k = 1024
const i = Math.floor(Math.log(num) / Math.log(k))
const value = num / k ** i

return `${value.toFixed(2).replace(/\.?0+$/, '')} ${units[i]}`
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot use pretty-bytes:

Note that it uses base-10 (e.g. kilobyte). Read about the difference between kilobyte and kibibyte.

FilBeam's pricing uses multiples of 1024, not base-10.

I could use byte-size (32 kB unpacked) or bytes-iec (23 kB unpacked), but do we really need to add so much weight to our dependencies?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we keep the current implementation, then I propose moving the helper to synapse-core.

Any objections?

</TooltipContent>
</Tooltip>
<span className="flex items-center gap-1 text-sm text-muted-foreground">
<Tooltip>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would make a custom tooltip component wrapping the globe icon with all the cdn info, using a hook to fetch the data.

check the other hooks that use tanstack query to wrap fetchDataSetEgressQuota

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make a custom tooltip component wrapping the globe icon with all the cdn info, using a hook to fetch the data.

Since we are fetching isCDN flag in a different network request than the egress quotas info, I feel it's better to keep the current globe & tooltip as-is, and let the new component handle only the part about egress quotas.

That's what I implemented in the new version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OTOH, I can see how it would make sense to move the entire <span> into a new component, growing EgressQuotaDisplay to something like CdnDetails.

{dataSet.cdn && <CdnDetails dataSetId={dataSet.dataSetId}/>}

Is that what you had in mind?

Can you suggest a better name for this new component?

@github-project-automation github-project-automation bot moved this from 🔎 Awaiting review to ⌨️ In Progress in FOC Jan 13, 2026
bajtos and others added 3 commits January 14, 2026 11:31
- Add filbeam module to synapse-core with getDataSetStats function
- Use iso-web/http request lib with proper error handling
- Add GetDataSetStatsError class for FilBeam API errors
- Add parseBigInt validation for API response values
- Create useEgressQuota hook in synapse-react
- Remove egress quota fetching from useDataSets hook
- Update playground to use new useEgressQuota hook

Co-Authored-By: Claude Code <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
Add unit tests for getStatsBaseUrl and validateStatsResponse functions.
Export validateStatsResponse to enable direct testing without HTTP mocking.

Also update AGENTS.md with testing guidelines:
- Use assert.deepStrictEqual for object comparisons
- Use parameterized tests with descriptive names

Co-Authored-By: Claude Code <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
just in case

Signed-off-by: Miroslav Bajtoš <[email protected]>
@bajtos bajtos requested a review from hugomrdias January 14, 2026 12:17
@bajtos bajtos moved this from ⌨️ In Progress to 🔎 Awaiting review in FOC Jan 14, 2026
@bajtos
Copy link
Contributor Author

bajtos commented Jan 14, 2026

@hugomrdias I addressed your comments, PTAL again.

@@ -1,9 +1,9 @@
import type { DataSetWithPieces, UseProvidersResult } from '@filoz/synapse-react'
import { useDeletePiece } from '@filoz/synapse-react'
import { useDeletePiece, useEgressQuota } from '@filoz/synapse-react'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we find a better name for this hook? E.g. useFetchEgressQuotas?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is a fetch egress quota? I don't think I've heard the term before

Copy link
Contributor Author

@bajtos bajtos Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed name is a combination of the "use" prefix, followed by a verb ("to fetch"), followed by the object ("egress quota").

Similarly to how `useDeletePiece" is a combination of the "use" prefix, the verb "to delete", and the object "piece".

How about useGetEgressQuotas - is that easier to understand?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see! I thought this was about a type of egress quota. I don't think we need a verb here, like there's also useState, and not useSetAndRetrieveState. I'd say useDeletePiece is a bit odd, but there the verb makes sense, since it's only one particular piece action.

Comment on lines 45 to 55
export function formatBytes(bytes: bigint | number): string {
const num = typeof bytes === 'bigint' ? Number(bytes) : bytes
if (num === 0) return '0 B'

const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB']
const k = 1024
const i = Math.floor(Math.log(num) / Math.log(k))
const value = num / k ** i

return `${value.toFixed(2).replace(/\.?0+$/, '')} ${units[i]}`
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we keep the current implementation, then I propose moving the helper to synapse-core.

Any objections?


return useQuery({
...props.query,
queryKey: ['synapse-filbeam-egress-quota', chainId, dataSetId?.toString()],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use the plural "quotas"?

Suggested change
queryKey: ['synapse-filbeam-egress-quota', chainId, dataSetId?.toString()],
queryKey: ['synapse-filbeam-egress-quotas', chainId, dataSetId?.toString()],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔎 Awaiting review

Development

Successfully merging this pull request may close these issues.

7 participants